package com.easonji.core.shiro.check;

import com.easonji.common.util.SpringContextHolder;

/**
 * @ClassName: PermissionCheckManager
 * @Description: 权限检查工厂
 * @Author: LiuJun
 * @date: 2018/07/09 11:29
 * @Version: 1.0
 * @Copyright: Copyright (c) 2018 - 2019
 */
public class PermissionCheckManager {

    private final static PermissionCheckManager ME = new PermissionCheckManager();

    private PermissionCheckFactory defaultCheckFactory = SpringContextHolder.getBean(PermissionCheckFactory.class);

    public static PermissionCheckManager me() {
        return ME;
    }

    private PermissionCheckManager() {
    }

    public PermissionCheckManager(PermissionCheckFactory checkFactory) {
        this.defaultCheckFactory = checkFactory;
    }

    public void setDefaultCheckFactory(PermissionCheckFactory defaultCheckFactory) {
        this.defaultCheckFactory = defaultCheckFactory;
    }

    public static boolean check(Object[] permissions) {
        return ME.defaultCheckFactory.check(permissions);
    }

    public static boolean checkAll() {
        return ME.defaultCheckFactory.checkAll();
    }
}
